<?php

/**
 * Description of Application_Model_Fields_Password
 *
 * @author Jean Brito
 */
abstract class Application_Model_Fields_Password {

    static protected function standField($field, $setup) {
        foreach ($setup as $i => $v)
            if (!isset($field[$i]))
                $field[$i] = $v;
        return $field;
    }

    static public function getCreateSql($setup) {
        $padrao = Array(
            'sqlType' => 'varchar',
            'sqlSize' => 45,
        );
        return self::standField($setup, $padrao);
    }
    static public function getInsertFieldSql($setup,$data) {
        $padrao = Array(
        );
        $setup['value']="SHA1('".$data."')";
        return self::standField($setup, $padrao);
    }

    static public function getStoreField($setup) {
        $padrao = Array(
            'extType' => 'string',
        );
        return self::standField($setup, $padrao);
    }

    static public function getGridColumn($setup) {
        $padrao = Array(
            'header'=>isset($setup['label'])?$setup['label']:$setup['name'],
            'dataIndex'=>$setup['name'],
            'flex'=>1,
        );
        return self::standField($setup, $padrao);
    }

    static public function getFormInput($setup) {
        $padrao = Array(
            'fieldLabel'=>isset($setup['label'])?$setup['label']:$setup['name'],
            'inputType'=>'password',
        );
        return self::standField($setup, $padrao);
    }
    
}
